/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Aleatorio.Distribuciones;

/**
 *
 * @author Driv
 */
public class GeneradorUniforme implements GeneradorAleatorio{
    
    private double multiplicador = 113;
    private double constanteAditiva = 1;
    private double modulo = 65536;
    private double semilla = 0;
    private double limiteInferior;
    private double limiteSuperior;
    
    public GeneradorUniforme (int semilla, double limiteInferior, double limiteSuperior) {
        this.semilla = semilla;
        this.limiteInferior = limiteInferior;
        this.limiteSuperior = limiteSuperior;
    }
    
    public GeneradorUniforme (int semilla) {
        this.semilla = semilla;
        this.limiteInferior = 0;
        this.limiteSuperior = 1;
    }
    
    public void setSemilla(int semilla) {
        if (semilla >= modulo) semilla = (int) (modulo % semilla);
        else this.semilla = semilla;
    }

    public double siguiente() {
        semilla = (multiplicador*semilla + constanteAditiva) % modulo;
        return (double)(semilla/modulo)*(limiteSuperior-limiteInferior) + limiteInferior;
    }
}
